<template>
  <view class="gjrwgl">
    <!-- <view
      class="info"
      v-for="(item, index) in infoData"
      :key="index"
      @tap="openDetail(index)"
    >
      <view class="info_header">
        <image src="../../../static/images/DCXT/renwu.png" mode="" />
        <view class="info_header_v">
          <view :style="getTypeColor(2)">攻坚任务</view>
          <view>{{ item.name }}</view></view
        >
      </view>
      <view class="item">
        <view>任务内容</view>
        <view>{{ item.rwnr }}</view>
      </view>
      <view class="item">
        <view>督查单位</view>
        <view>{{ item.dcdw }}</view>
        <view
          class="state"
          :style="getStateColor(item.state)"
          v-show="item.state === '0'"
          >待审批</view
        >
        <view
          class="state"
          :style="getStateColor(item.state)"
          v-show="item.state === '1'"
          >审批未通过</view
        >
        <view
          class="state"
          :style="getStateColor(item.state)"
          v-show="item.state === '2'"
          >正常待完成</view
        >
        <view
          class="state"
          :style="getStateColor(item.state)"
          v-show="item.state === '3'"
          >新反馈</view
        >
        <view
          class="state"
          :style="getStateColor(item.state)"
          v-show="item.state === '4'"
          >已完成</view
        >
        <view
          class="state"
          :style="getStateColor(item.state)"
          v-show="item.state === '9'"
          >待立项</view
        >
      </view>
      <view class="item">
        <view>派发时间</view>
        <view>{{ item.pfsj }}</view>
      </view>
    </view> -->
    <view
      v-for="(item, index) in infoData"
      :key="index"
      class="task_one"
      @tap="openDetail(index)"
    >
      <view class="task_left_top">
        <view class="task_round">
          <image src="../../../static/images/common/task.png" mode=""></image>
        </view>
        <view class="name">攻坚任务</view>
      </view>
      <view class="task_content">
        <view class="task_name">
          <view class="task_left">任务名称</view>
          <view class="task_right nameFont">{{ item.name }}</view>
        </view>
        <view class="task_child">
          <view class="task_test">
            <view class="task_left">任务内容</view>
            <view class="task_right childFont">{{ item.rwnr }}</view>
          </view>
          <view class="task_test">
            <view class="task_left">督查单位</view>
            <view class="task_right childFont">{{ item.dcdw }}</view>
          </view>
          <view class="task_test">
            <view class="task_left">派发时间</view>
            <view class="task_right childFont">{{ item.pfsj }}</view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { getGjtasklist } from "../../../request/dcxt";
export default {
  data() {
    return {
      infoData: [],
    };
  },
  onShow() {
    this.getData();
  },
  methods: {
    getTypeColor(type) {
      if (type == "1") {
        return "backgroundColor:rgba(250, 173, 51, 0.1);color:rgba(250, 173, 51, 1);";
      }
      if (type == "2") {
        return "backgroundColor:rgba(48, 116, 255, 0.1);color:rgba(48, 116, 255, 1);";
      }
    },
    getStateColor(state) {
      if (state == "0" || state == "1" || state == "2") {
        return "backgroundColor:rgba(248, 95, 120, 1);color:#fff;";
      }
      if (state == "3" || state == "4" || state == "9") {
        return "backgroundColor:rgba(250, 173, 51, 1);color:#fff;";
      }
    },
    openDetail(index) {
      var _this = this;
      uni.navigateTo({
        url:
          "/pages/dcxt/gjrwgl/detail/index?info=" +
          JSON.stringify(_this.infoData[index]),
      });
    },
    getData() {
      var params = {
        loginerId: uni.getStorageSync("loginId"),
      };
      getGjtasklist(params).then((res) => {
        console.log(res.data.data);
        var result = res.data.data;
        var arr = [];
        for (let i = 0; i < result.length; i++) {
          arr.push({
            name: result[i].mainName
              .replace("&ldquo;", "")
              .replace("&rdquo;", ""),
            state: result[i].status,
            rwnr: result[i].content
              .replace("&ldquo;", "")
              .replace("&rdquo;", ""),
            dcdw: result[i].inspectionName ? result[i].inspectionName : "",
            pfsj: result[i].timeLimit,
            gjId: result[i].gjId,
          });
        }
        this.infoData = JSON.parse(JSON.stringify(arr));
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.gjrwgl {
  padding-top: 20rpx;
  // .info {
  //   width: 710rpx;
  //   background: #ffffff;
  //   box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(48, 116, 255, 0.1);
  //   border-radius: 8rpx;
  //   margin: 0 auto;
  //   margin-bottom: 40rpx;
  //   padding: 40rpx 24rpx;
  //   .info_header {
  //     display: flex;
  //     flex-flow: row nowrap;
  //     justify-content: flex-start;
  //     align-items: center;
  //     border-bottom: 1rpx solid rgba(231, 233, 240, 1);
  //     padding-bottom: 20rpx;
  //     image {
  //       width: 40rpx;
  //       height: 40rpx;
  //       margin-right: 20rpx;
  //     }
  //     .info_header_v {
  //       flex: 1;
  //       display: flex;
  //       flex-flow: row nowrap;
  //       justify-content: space-between;
  //       align-items: center;
  //       view:nth-child(1) {
  //         font-size: 24rpx;
  //         font-family: PingFang SC;
  //         font-weight: 500;
  //         border-radius: 4rpx;
  //         padding: 8rpx 16rpx;
  //       }
  //       view:nth-child(2) {
  //         font-size: 28rpx;
  //         font-family: PingFang SC;
  //         font-weight: bold;
  //         color: #272b32;
  //         margin-left: 20rpx;
  //       }
  //     }
  //   }
  //   .item {
  //     display: flex;
  //     flex-flow: row nowrap;
  //     justify-content: flex-start;
  //     align-items: center;
  //     margin-top: 18rpx;
  //     position: relative;
  //     padding-bottom: 20rpx;
  //     //   border-bottom: 1rpx solid rgba(231, 233, 240, 1);
  //     view:nth-child(1) {
  //       width: 140rpx;
  //       font-size: 24rpx;
  //       font-family: PingFang SC;
  //       font-weight: 400;
  //       color: #8e9cb3;
  //     }
  //     view:nth-child(2) {
  //       flex: 1;
  //       font-size: 28rpx;
  //       font-family: PingFang SC;
  //       font-weight: 400;
  //       color: #272b32;
  //     }
  //     .state {
  //       display: inline-block;
  //       font-size: 20rpx;
  //       font-family: PingFang SC;
  //       font-weight: 400;
  //       color: #ffffff;
  //       border-radius: 4rpx;
  //       padding: 8rpx 16rpx;
  //       position: absolute;
  //       right: 20rpx;
  //       top: -10rpx;
  //     }
  //   }
  // }
  .task_one {
    background-color: rgba(255, 255, 255, 1);
    padding: 24rpx;
    position: relative;
    margin-bottom: 40rpx;
    box-shadow: 0px 0px 24rpx 0px rgba(48, 116, 255, 0.1);
    border-radius: 24rpx 8rpx 8rpx 8rpx;

    .task_left_top {
      position: absolute;
      top: 0;
      left: 0;
      min-width: 200rpx;
      height: 48rpx;
      background: rgba(48, 116, 255, 0.2);
      border-radius: 24rpx;
      display: flex;
      align-items: center;

      .name {
        font-size: 20rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #3074ff;
        padding: 0 20rpx;
      }

      .task_round {
        width: 48rpx;
        height: 48rpx;
        background: #3074ff;
        z-index: 5;
        box-shadow: 2px 3px 12px 0px rgba(48, 116, 255, 0.4);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;

        image {
          width: 24rpx;
          height: 24rpx;
        }
      }
    }

    .task_content {
      width: 100%;
      margin-top: 40rpx;

      .task_btnArr {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        margin-top: 40rpx;
      }

      .task_btn {
        background: #3074ff;
        border-radius: 4rpx;
        padding: 8rpx 16rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 20rpx;

        image {
          width: 24rpx;
          height: 24rpx;
          margin-right: 10rpx;
        }

        .more {
          width: 24rpx;
          height: 6rpx;
          margin-right: 10rpx;
        }

        .font {
          font-size: 24rpx;
          font-family: PingFang SC;
          font-weight: 400;
          color: rgba(255, 255, 255, 0.7);
        }
      }

      .btn_color1 {
        // background-color: rgba(231, 233, 240, 1);
        background-color: #5cb85c;
      }

      .btn_color2 {
        background-color: rgba(248, 95, 120, 1);
      }
      .btn_color3 {
        background-color: #5cb85c;
      }

      .task_name {
        display: flex;
        padding-bottom: 40rpx;
      }

      .task_child2 {
        padding: 20rpx 0;
      }
      .task_child {
        padding: 20rpx 0;
        border-top: 1rpx solid rgba(231, 233, 240, 1);
        border-bottom: 1rpx solid rgba(231, 233, 240, 1);
      }

      .task_test {
        display: flex;
        margin: 20rpx 0;
      }

      .task_left {
        flex: 2;
        font-size: 24rpx;
        font-family: PingFang SC;
        font-weight: 400;
        color: #8e9cb3;
      }

      .nameFont {
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #272b32;
      }

      .task_right {
        flex: 7;
        display: flex;
        align-items: center;
        word-break: break-all;

        .childFont {
          font-size: 28rpx;
          font-family: PingFang SC;
          font-weight: 400;
          color: #272b32;
          word-break: break-all;
        }

        .zt_type1 {
          margin-left: 10rpx;
          background: #f85f78;
          border-radius: 4rpx;
          font-size: 20rpx;
          font-family: PingFang SC;
          font-weight: 400;
          color: rgba(255, 255, 255, 0.7);
          padding: 0 16rpx;
          display: flex;
          align-items: center;
          justify-content: center;
        }

        .zt_type2 {
          margin-left: 10rpx;
          background: rgba(250, 173, 51, 1);
          border-radius: 4rpx;
          font-size: 20rpx;
          font-family: PingFang SC;
          font-weight: 400;
          color: rgba(255, 255, 255, 0.7);
          padding: 0 16rpx;
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }
    }
  }
}
</style>
